<?php

namespace App\Http\Requests\Logic\Conference;

use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;

class StoreResource extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

	/**
	 * 定义表单验证规则
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return array
	 */
    public function rules()
    {
        return [
            'attendee' => 'required',
            'type' => [
                'required',
                Rule::in(array_keys(config('system.conference.type')))
            ],
        	'start_time' => 'required|date',
            'end_time' => 'required|date',
            'address' => 'required|string',
            'content' => 'required|string',
            'comment' => 'nullable'
        ];
    }

	/**
	 * 定义表单验证错误消息
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
            'attendee.required' => '请选择参与人',
            'type.required' => '请输入会议类型',
            'type.in' => '会议类型不存在',
			'start_time.required' => '请选择会议开始日期',
            'start_time.date' => '请输入正确日期',
            'end_time.required' => '请选择会议结束时间',
            'end_time.date' => '请输入正确日期',
            'address.required' => '请输入地址',
            'address.string' => '请输入正确地址',
			'content.required' => '请输入会议内容',
            'content.string' => '请输入正确的会议内容'
        ];
    }
}
